<template>
  <div>
    <h1>App</h1>
    <button @click="isShow = !isShow">按钮</button>
    <!-- keep-alive是vue的内置组件，缓存组件 -->
    <keep-alive>
      <Child v-if="isShow" />
    </keep-alive>
  </div>
</template>

<script>
import Child from "./Child.vue";

export default {
  name: "App",
  components: {
    Child,
  },
  data() {
    return {
      isShow: true,
    };
  },
  errorCaptured(error) {
    console.log(error); // 错误上报
  },
};
</script>

<style></style>
